package com.gzx.plugin.fin.tech.service;

import com.alibaba.fastjson2.JSONObject;
import com.gzx.plugin.fin.tech.enums.GzxFinTechErrorEnum;
import jakarta.servlet.http.HttpServletRequest;

import java.util.List;

/**
 * @author zjt
 * @description
 * @since 2025/4/2 16:36
 */
public interface GzxFinTechService {

    /**
     * 正常评分
     *
     * @param reqBody
     * @param httpServletRequest
     * @return
     */
    String forwardScoring(String reqBody, HttpServletRequest httpServletRequest);

    /**
     * 回溯评分
     *
     * @param reqBody
     * @param httpServletRequest
     * @return
     */
    String backtrackScoring(String reqBody, HttpServletRequest httpServletRequest);

    /**
     * 构建成功响应
     */
    default String buildSuccessResponse(JSONObject data) {
        JSONObject response = new JSONObject();
        response.put("code", 200);
        response.put("msg", "success");
        response.put("data", data);
        return response.toJSONString();
    }

    /**
     * 构建错误响应
     */
    default String buildErrorResponse(GzxFinTechErrorEnum finTechErrorEnum) {
        JSONObject response = new JSONObject();
        response.put("code", finTechErrorEnum.getCode());
        response.put("msg", finTechErrorEnum.getMsg());
        response.put("data", List.of());
        return response.toJSONString();
    }
}
